package TP2.sorters;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;


public class BubbleSorter extends AbstractSorter {

    public BubbleSorter(){
        this(SorterType.BUBBLE);
    }

    protected BubbleSorter(final SorterType type){
        super(type);
    }

    public <T> void sort(Comparator<T> comparator, List<T> list){
        int n = list.size();
                for(int i=0; i < n-1; i++){
                    for(int j=i+1; j < n; j++){
                        if(greater(comparator, list, i, j)){
                            swap(list, i, j);
                        }
                    }
                }
    }

}
